/**
 * Created by Administrator on 2019/4/25 0025.
 */
/**
 *
 * @param form
 */
function singwaapp_save(form) {
    var data = $(form).serialize();
    // console.log(data);
    url = $(form).attr('url');
    $.post(url, data, function (result) {
        if(result.code == 0){
            layer.msg(result.msg,{icon:5, time:2000});
        }else if(result.code == 1){
            self.location = result.data.jump_url;
        }
    },'JSON');
}
/**
 * 时间插件适配方法
 * @param flag
 */
function selecttime(flag){
    if(flag==1){
        var endTime = $("#countTimeend").val();
        if(endTime != ""){
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',maxDate:endTime})}else{
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})}
    }else{
        var startTime = $("#countTimestart").val();
        if(startTime != ""){
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',minDate:startTime})}else{
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})}
    }
}
/**
 * 删除通用方法
 * @param obj
 * @param id
 */
function app_del(obj,id){
    var url = $(obj).attr('del_url');
    // console.log(url);
    layer.confirm('确认要删除吗？',function(index){
        $.ajax({
            type: 'POST',
            url: url,
            dataType: 'json',
            success: function(data){
               if(data.code == 1){
                   self.location = data.data.jump_url;
               }else if(data.code == 0){
                    layer.msg(data.msg,{icon:2,time:2000});
               }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });
    });
}

/**
 * 状态修改的通用方法
 * @param obj
 * @param id
 */
function app_status(obj,id){
    var url = $(obj).attr('status_url');
    // console.log(url);
    layer.confirm('确认要修改状态吗？',function(index){
        $.ajax({
            type: 'POST',
            url: url,
            dataType: 'json',
            success: function(data){
                if(data.code == 1){
                    self.location = data.data.jump_url;
                }else if(data.code == 0){
                    layer.msg(data.msg,{icon:2,time:2000});
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });
    });
}